<?php
$width=Yii::app()->params['dialog']['findTruckForMeritRatio']['width'];
$height=Yii::app()->params['dialog']['findTruckForMeritRatio']['height'];
$width1=Yii::app()->params['dialog']['findTypeForMeritRatio']['width'];
$height1=Yii::app()->params['dialog']['findTypeForMeritRatio']['height'];
$cs=Yii::app()->clientScript;
$cs->registerScriptFile('./js/modal.js');
$cs->registerScript('type_merit_ratio_dialog',<<<END
function Block(){\$.modal('?r=dialog/findTruckForMeritRatio',{width:$width,height:$height,title:'请选择车辆'});return false;}
function Block1(){\$.modal('?r=dialog/findTypeForMeritRatio',{height:$height1,width:$width1,title:'请选择车型'});return false;}	
$("#findTruck").click(Block);
$("#findType").click(Block1);
var truck_merit;
function check_merit(){
	if(!$("#ejsvformid1").valid()) return false;
	$.ajax({'type':'POST','url':'?r=merit_pay_ratio/checkMerit','async':false,'cache':false,'data':'truck_id='+$("#fk_truck_id").val()+'&effect_date='+$('#effect_date').val()+'&lapse_date='+$('#lapse_date').val()+'&merit_id=$model->id','success':function(data){truck_merit=data;}});
	if(truck_merit==1) {alert("此车辆相对应时间段的绩效工资系数已存在!");return false;}
	return true;
}
$('form').submit(check_merit);
END
)
?>
<div class="yiiForm">
<?php
	echo EHtml::form();	
	EHtml::setOptions(array('errorElement'=> 'span'));
	EHtml::setScenario($update ? 'update' : 'create');				  		
?>
<div>注：<span class="required">*</span>为必填项,不存在的分档填"0"</div>
<div id="leftaa">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'plate_no'); ?>
<?php echo EHtml::activeTextField($model,'plate_no',array('size'=>10,'maxlength'=>10,'class'=>'readonly','readOnly'=>'true','id'=>'plate_no')); ?>&nbsp;&nbsp;<a id="findTruck" href="#">查找车辆</a>
<?php echo CHtml::activeHiddenField($model,'fk_truck_id',array('id'=>'fk_truck_id'));?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'kind'); ?>
<?php echo EHtml::activeDropDownList($model,'kind',$model->getKindOptions()); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'a_profit_min'); ?>
<?php echo EHtml::activeTextField($model,'a_profit_min',array('size'=>8)); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'a_profit_max'); ?>
<?php echo EHtml::activeTextField($model,'a_profit_max',array('size'=>8)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'a_ratio'); ?>
<?php if($update):?>
<?php echo EHtml::activeTextField($model,'a_ratio',array('value'=>$model->a_ratio*100,'size'=>8)); ?>
<?php else:?>
<?php echo EHtml::activeTextField($model,'a_ratio',array('size'=>8)); ?>
<?php endif;?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'b_profit_min'); ?>
<?php echo EHtml::activeTextField($model,'b_profit_min',array('size'=>8)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'b_profit_max'); ?>
<?php echo EHtml::activeTextField($model,'b_profit_max',array('size'=>8)); ?>
</div>
<div class="simple1" style="border-bottom:0px;">
<?php echo CHtml::activeLabelEx($model,'b_ratio'); ?>
<?php if($update):?>
<?php echo EHtml::activeTextField($model,'b_ratio',array('value'=>$model->b_ratio*100,'size'=>8)); ?>
<?php else:?>
<?php echo EHtml::activeTextField($model,'b_ratio',array('size'=>8)); ?>
<?php endif;?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'effect_date'); ?>
<?php echo EHtml::activeTextField($model,'effect_date',array('size'=>8,'maxlength'=>10,'id'=>"effect_date",'value'=>substr($model->effect_date,0,7))); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'effect_date','ifFormat'=>'%Y-%m',));?>
(从此月初生效)
</div>
</div>
<div id="rightaa">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'type'); ?>
<?php echo EHtml::activeTextField($model,'type',array('size'=>10,'maxlength'=>20,'class'=>'readonly','readOnly'=>'true','id'=>'type')); ?><!--  &nbsp;&nbsp;<a id="findType" href="#">查找车型</a>-->
<?php echo CHtml::activeHiddenField($model,'fk_type_id',array('id'=>'fk_type_id'));?>
</div>
<div class="simple1">
</div>  
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'c_profit_min'); ?>
<?php echo EHtml::activeTextField($model,'c_profit_min',array('size'=>8)); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'c_profit_max'); ?>
<?php echo EHtml::activeTextField($model,'c_profit_max',array('size'=>8)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'c_ratio'); ?>
<?php if($update):?>
<?php echo EHtml::activeTextField($model,'c_ratio',array('value'=>$model->c_ratio*100,'size'=>8)); ?>
<?php else:?>
<?php echo EHtml::activeTextField($model,'c_ratio',array('size'=>8)); ?>
<?php endif;?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'d_profit_min'); ?>
<?php echo EHtml::activeTextField($model,'d_profit_min',array('size'=>8)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'d_profit_max'); ?>
<?php echo EHtml::activeTextField($model,'d_profit_max',array('size'=>8)); ?>
</div>
<div class="simple1" style="border-bottom:0px;">
<?php echo CHtml::activeLabelEx($model,'d_ratio'); ?>
<?php if($update):?>
<?php echo EHtml::activeTextField($model,'d_ratio',array('value'=>$model->d_ratio*100,'size'=>8)); ?>
<?php else:?>
<?php echo EHtml::activeTextField($model,'d_ratio',array('size'=>8)); ?>
<?php endif;?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'lapse_date'); ?>
<?php echo EHtml::activeTextField($model,'lapse_date',array('size'=>8,'maxlength'=>10,'id'=>"lapse_date",'value'=>substr($model->lapse_date,0,7))); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'lapse_date','ifFormat'=>'%Y-%m',));?>
(至此月末失效)
</div>
</div>
<div class="action">
<?php echo EHtml::submitButton($update ? '更新信息' : '添加信息'); ?>
</div>

<?php echo EHtml::endForm(); ?>

</div><!-- yiiForm -->
<?php 
if($model->hasErrors()) echo "<script>alert('您填写的信息有误！请根据页面红色图标提示修改。');</script>";
?>